package com.ruoyi.web.controller.gd;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.gd.todo.domain.vo.ZTodoFlVo;
import com.ruoyi.gd.todo.domain.bo.ZTodoFlBo;
import com.ruoyi.gd.todo.service.IZTodoFlService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 待办内容分类
 *
 * @author ruoyi
 * @date 2024-11-19
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/gd/todoFl")
public class ZTodoFlController extends BaseController {

    private final IZTodoFlService iZTodoFlService;

    /**
     * 查询待办内容分类列表
     */
    @GetMapping("/list")
    public List<ZTodoFlVo> list(ZTodoFlBo bo) {
        List<ZTodoFlVo> zTodoFlVos = iZTodoFlService.queryList(bo);
        return zTodoFlVos;
    }

    /**
     * 导出待办内容分类列表
     */
    @Log(title = "待办内容分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZTodoFlBo bo, HttpServletResponse response) {
        List<ZTodoFlVo> list = iZTodoFlService.queryList(bo);
        ExcelUtil.exportExcel(list, "待办内容分类", ZTodoFlVo.class, response);
    }

    /**
     * 获取待办内容分类详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<ZTodoFlVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable String id) {
        return R.ok(iZTodoFlService.queryById(id));
    }

    /**
     * 新增待办内容分类
     */
    @Log(title = "待办内容分类", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZTodoFlBo bo) {
        return toAjax(iZTodoFlService.insertByBo(bo));
    }

    /**
     * 修改待办内容分类
     */
    @Log(title = "待办内容分类", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZTodoFlBo bo) {
        return toAjax(iZTodoFlService.updateByBo(bo));
    }

    /**
     * 删除待办内容分类
     *
     * @param ids 主键串
     */
    @Log(title = "待办内容分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(iZTodoFlService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
